﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using CUWo.Common.Entities.WoInterface;
using CUWo.Common.Entities.WoInterface.HttpArgument;

/**
 * 创建时间：2014/11/3 15:20:51
 * 作者：yong.blackcore
 * Email：itblackhole@outlook.com
 * QQ：50404503
 */
namespace CUWo.Common.WoInterfaceCommunication
{

    public class MobileSign : CommunicationBase
    {
        public MobileSign()
            : base()
        { }

                
        public string GetUrl(string mobileNumber,string password)
        {
            ArgsBase argsBase = base.InitHttpCommBass<ArgsMobileRegister>();
            ArgsMobileRegister args = argsBase as ArgsMobileRegister;
            args.MobileNumber = mobileNumber;
            args.Password = password;
            //
            StringBuilder requestUrl = new StringBuilder();
            requestUrl.Append(base.ServiceAddress);//请求地址
            requestUrl.Append(base.Method_MobileSign);//功能ID
            requestUrl.Append("?");
            requestUrl.Append(string.Concat(base.ServiceAddressRequestQueryChannelKey, "=", base.CHANNEL_ID));
            requestUrl.Append("&");
            requestUrl.Append(string.Concat(base.ServiceAddressRequestQueryKey, "="));
            //
            //AES加密
            string cipherString = JSONHelper.Serialize<ArgsMobileRegister>(args);
            string result = AESHelper.Byte2Hex(new AESHelper(AESHelper.KeySize.Bits128, AESHelper.Hex2Byte(base.CHANNEL_PASSWORD)).Cipher(Encoding.UTF8.GetBytes(cipherString)));
            requestUrl.Append(result);
            //
            LogHelper.LogInfo(requestUrl.ToString(), this.GetType(), MethodBase.GetCurrentMethod());
            //
            return requestUrl.ToString();
        }
    }
}
